package com.yc.myinfo.servlet;

import com.ly.common.servlet.BaseServlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

@WebServlet("/servlet/*")
public class HelloServlet extends BaseServlet {

    // 该方法不是继承, 但是要求接受请求和相应对象
    // 方法的返回结果会自动的转换成 json 格式
    // http://127.0.0.1:8080/C118_S3_Ply_myinfo_war/servlet/hello
    public String hello(
            javax.servlet.http.HttpServletRequest request,
            javax.servlet.http.HttpServletResponse response)
            throws ServletException, IOException {
        return "hello world";
    }

    // http://127.0.0.1:8080/C118_S3_Ply_myinfo_war/servlet/say
    public Map<String,Object> say(
            javax.servlet.http.HttpServletRequest request,
            javax.servlet.http.HttpServletResponse response)
            throws ServletException, IOException {
      Map<String,Object> ret = new HashMap<>();
      ret.put("name","zhangsan");
      ret.put("age","18");
      return ret;
    }
}
